import pymysql

class mysql():
    def __init__(self):
        self.con=pymysql.connect(host='10.59.9.14',user='root',password='yidong666',db='a3mall')
        self.cur=self.con.cursor()
    def select(self,sql):
        self.cur.execute(sql)
        return self.cur.fetchall()

a=mysql()
print(a.select('select id from mall_goods_category'))
print(a.select('select id,goods_id from mall_goods_extends '))
print(a.select('select * from mall_goods_image where id=76'))
print(a.select('select * from mall_goods_item where market_price > 20'))
print(a.select('select * from mall_goods_model '))
print(a.select('select * from mall_luckdraw where name LIKE \'%谢谢%\''))
print(a.select('select * from mall_navigation ORDER BY sort DESC'))
print(a.select('select * from mall_oauth where name LIKE \'%Q%\''))
# 获取第 11 - 20 条记录
print(a.select('select * from mall_order LIMIT 10 OFFSET 10'))
#空表
print(a.select('select * from mall_order_batch_shipping'))
# 总行数
print(a.select('select COUNT(*) from mall_order_collection'))
print(a.select('select * from mall_order_delivery'))
# real_price表里面的总价格
print(a.select('select SUM(real_price) from mall_order_goods'))
# sell_price平均的价格
print(a.select('select AVG(sell_price) from mall_order_group'))
# 统计 mall_order_log 表中，每个 create_time 时间点的订单数量
print(a.select('select create_time, COUNT(*) from mall_order_log GROUP BY create_time'))
print(a.select('select * from mall_order_refundment'))
print(a.select('select * from mall_pages where code LIKE  \'%me%\''))
print(a.select('select pid from mall_pages_items'))
print(a.select('select type from mall_pages_relation'))
print(a.select('select * from mall_pages_type where status=0'))
print(a.select('select * from mall_pages_widget where name LIKE \'%图片%\''))
print(a.select('select * from mall_payment LIMIT 1 OFFSET 3'))
print(a.select('select create_time, COUNT(*) from mall_products_attribute GROUP BY create_time'))
print(a.select('select * from mall_products_attribute_data where id=1'))
print(a.select('select name from mall_products_brand'))
print(a.select('select * from mall_products_model'))
print(a.select('select * from mall_products_model_data'))

